import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store/index.js'

Vue.use(VueRouter)

const routes = [{
		path: '/',
		name: 'page',
		component: () => import('@/views/page.vue'),
	}, {
		path: '/index',
		name: 'index',
		component: () => import('@/views/index.vue'),
	}, {
		path: '/index2',
		name: 'index2',
		component: () => import('@/views/index2.vue'),
	}, {
		path: '/index3',
		name: 'index3',
		component: () => import('@/views/index3.vue'),
	}, 
	// {
	// 	path: '/video',
	// 	name: 'video',
	// 	component: () => import('@/views/video.vue'),
	// },
	{
		path: '/about',
		name: 'about',
		component: () => import('@/views/about.vue'),
	}, {
		path: '/certificates',
		name: 'certificates',
		component: () => import('@/views/certificates.vue'),
	}, {
		path: '/paper',
		name: 'paper',
		component: () => import('@/views/paper.vue'),
	}, {
		path: '/Trading',
		name: 'Trading',
		component: () => import('@/views/tabBar/Trading.vue'),

	},{
		path: '/Order',
		name: 'Order',
		component: () => import('@/views/tabBar/Order.vue'),
	}, {
		path: '/Automatic',
		name: 'Automatic',
		component: () => import('@/views/Automatic/index.vue'),

	},{
		path: '/My',
		name: 'My',
		component: () => import('@/views/tabBar/My.vue'),
	}, {
		path: '/agent',
		name: 'agent',
		component: () => import('@/views/My/agent.vue'),
	}, {
		path: '/gd_order',
		name: 'gd_order',
		component: () => import('@/views/My/gd_order.vue'),
	},{
		path: '/record',
		name: 'record',
		component: () => import('@/views/My/record.vue'),
	},{
		path: '/help',
		name: 'help',
		component: () => import('@/views/My/help.vue'),
	}, {
		path: '/identity',
		name: 'identity',
		component: () => import('@/views/My/identity.vue'),
	},{
		path: '/Grade',
		name: 'Grade',
		component: () => import('@/views/My/Grade.vue'),
	}, {
		path: '/Manuals',
		name: 'Manuals',
		component: () => import('@/views/My/Manuals.vue'),
	}, {
		path: '/asset',
		name: 'asset',
		component: () => import('@/views/My/asset.vue'),
	}, {
		path: '/invite',
		name: 'invite',
		component: () => import('@/views/My/invite.vue'),
	}, {
		path: '/kefu',
		name: 'kefu',
		component: () => import('@/views/My/kefu.vue'),
	},

	// {
	// 	path: '/',
	// 	name: 'home',
	// 	component: () => import('@/views/home.vue'),
	// 	meta: {
	// 		showTabs: false,
	// 		auth: false
	// 	}
	// },
]


const router = new VueRouter({
	//mode: 'history',
	// base: process.env.BASE_URL,
	routes
})

router.beforeEach((to, from, next) => {
	const {
		meta: {
			showTabs,
			auth
		}
	} = to
	const isShow = !!showTabs
	if (store.state.showTabs !== isShow) {
		//修改底部tab栏显示或隐藏
		store.commit('toggleTabs', isShow)
	}
	// if (auth && store.state.user.id === 0 && store.state.oauthInit) {
	//   console.log(auth,store.state.user.id === 0, store.state.oauthInit);
	//   //访问需要登录权限，直接重定向到登录页面
	//   next({ path: '/login' })
	// }
	next()
})

export default router
